home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / PowerPlant / AMReminder / CReminder.cp < prev    next >
Encoding:
Text File  |  1998-10-11  |  3.0 KB  |  136 lines  |  [TEXT/CWIE]

  1. // CReminder.cp -- panel methods
  2.  
  3. #include "CReminder.h"
  4.  
  5. #include <UEnvironment.h>
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <LTabGroup.h>
  10. #include <LStaticText.h>
  11. #include <LAMStaticTextImp.h>
  12. #include <LGAStaticTextImp.h>
  13. #include <LSeparatorLine.h>
  14. #include <LAMControlImp.h>
  15. #include <LGASeparatorImp.h>
  16. #include <CTextUtils.h>
  17.  
  18. #include "DReminder.h"
  19. #include "DDocData.h"
  20. #include "AMReminderCmds.h"
  21.  
  22.  
  23. #define PPob_ReminderID    203
  24. #define RidL_ReminderID    203
  25.  
  26. Boolean        CReminder::sIsRegistered = false;
  27.  
  28. //----------
  29. CReminder*        CReminder::CreateReminder (
  30.     LView*        inSuperView,
  31.     LCommander*        inSuperCommander)
  32. {
  33.     if (!sIsRegistered) {
  34.         RegisterClass ();
  35.     }
  36.  
  37.     CReminder*        panel;
  38.     panel = (CReminder *)UReanimator::CreateView (PPob_ReminderID, inSuperView, inSuperCommander);
  39.     return panel;
  40. }
  41.  
  42. //----------
  43. #define    RegisterClasses(AbstractClass,AMImpClass,GAImpClass)    \
  44.     RegisterClass_(AbstractClass);    \
  45.     if (useAppearance) {    \
  46.         RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID);    \
  47.     } else {    \
  48.         RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID);    \
  49.     }
  50.  
  51. //----------
  52. void    CReminder::RegisterClass ()
  53. {
  54.     Boolean        useAppearance = UEnvironment::HasFeature (env_HasAppearance);
  55.  
  56.     RegisterClass_(CReminder);
  57.  
  58.     // register the pane classes we use
  59.     RegisterClasses (LStaticText, LAMStaticTextImp, LGAStaticTextImp);
  60.     RegisterClasses (LSeparatorLine, LAMControlImp, LGASeparatorImp);
  61.  
  62.     sIsRegistered = true;
  63. }
  64.  
  65. //----------
  66. CReminder::CReminder (
  67.     LStream*    inStream)
  68.     : AMPanel (inStream)
  69. {
  70. }
  71.  
  72. //----------
  73. CReminder::~CReminder ()
  74. {
  75. }
  76.  
  77. //----------
  78. //    This member function gets called once the containment hierarchy that contains
  79. //    this pane has been built. It gives us a chance to get data members for
  80. //    interesting subviews, and to do other operations now that our subviews exist.
  81. void    CReminder::FinishCreateSelf ()
  82. {
  83.     mCap112299Label = (LStaticText*) FindPaneByID ('Ca99');
  84.  
  85.     mCap1234PMLabel = (LStaticText*) FindPaneByID ('CapM');
  86.  
  87.     mCapMessageLabel = (LStaticText*) FindPaneByID ('Cape');
  88.  
  89.  
  90.     UReanimator::LinkListenerToControls(this, this, RidL_ReminderID);
  91.         // "connect" self to our controls that we want to "listen" to
  92.  
  93.     // any additional initialization for your panel:
  94. }
  95.  
  96. //----------
  97. void    CReminder::ConnectToData (
  98.     AMDataDef*        inData)
  99. {
  100.     mData = (DReminder*)inData;
  101.     mData->AddListener (this);
  102.  
  103.     mCap112299Label->SetDescriptor (mData->GetDateString ());
  104.     mCap1234PMLabel->SetDescriptor (mData->GetTimeString ());
  105.     mCapMessageLabel->SetDescriptor (mData->GetMessage ());
  106. }
  107.  
  108. //----------
  109. void    CReminder::DataChanged (
  110.     long        inDataID)
  111. {
  112.     StopListening ();
  113.  
  114.     mCap112299Label->SetDescriptor (mData->GetDateString ());
  115.     mCap1234PMLabel->SetDescriptor (mData->GetTimeString ());
  116.     mCapMessageLabel->SetDescriptor (mData->GetMessage ());
  117.  
  118.     StartListening ();
  119. }
  120.  
  121. //----------
  122. void    CReminder::ListenToMessage (
  123.     MessageT    inMessage,
  124.     void*        ioParam)
  125. {
  126.     switch (inMessage) {
  127.     case msgDataChanged:
  128.             DataChanged ((long)ioParam);
  129.         break;
  130.  
  131.     default:
  132.           ; // do something
  133.         break;
  134.     }
  135. }
  136.